$(document).ready( function() {

    $('#descripcion').blur( function () {

        fieldName = $(this).attr('id');
        fieldValue = $(this).val();

        $.post('/cake/syscable/mg_departamentos/ajax_validate', {
                                        field: fieldName,
                                        value: fieldValue
                                        },
               function(error) {
                                        	
                                        	                                        	
                   if(error.length != 0) {                
                		if($('#' + fieldName + '-exists').length == 1){
                    		$('#' + emailField + '-exists').remove();
                    		}
                       $('#descripcion').after('<div class="error-message" id="'+ fieldName +'-exists">' + error + '</div>');
                       $('#descripcion').addClass('form-error');
                   }
                   else {
                       $('#' + fieldName + '-exists').remove();
                       $('#descripcion').removeClass('form-error');
                       $('#descripcion').addClass('reqaceptado');
                   }
               });
     });   

});
/*
$(�fieldset [id^=Contact]�).blur(function() {
	fieldName = $(this).attr(�id�);
	fieldValue = $(this).attr(�value�);
	fieldValidate = fieldName.substr(7).toLowerCase();

	$.post(�/cega/contact/ajax_validate�, {
	field: fieldValidate,
	value: fieldValue
	},

	function(error) {
	if(error.length > 2) {
	if($(�#'+ fieldName +�-exists�).length == 0) {
	$(�#'+ fieldName).after(�+ error +�);
	}
	} else {
	$(�#'+ fieldName +�-exists�).remove();
	}
	});
	});
/*
 * <script type="text/javascript"> // Look for all req fields and put them in an
 * array requiredFields = document.getElementsByClassName('req');
 *  // Loop the array and place observers on the req fields for(i=0; i<requiredFields.length;i++){
 * new Form.Element.Observer(requiredFields[i], 2, liveActionCallback); }
 *  // Callback if something happens in one of the req fields function
 * liveActionCallback( element, value ) {
 *  // Funcion for handling the response XML file wich the Ajax.Request below
 * gets for us var handlerFunc = function(t) { var xmlDoc =
 * t.responseXML.documentElement; // Check if there is an error
 * if(xmlDoc.getElementsByTagName('error')[0].firstChild.nodeValue == '1'){ //
 * You could do all kinds of stuff here, i'm just adding a classname to the form
 * field wich makes it red $(element).addClassName('form-error'); } else { // if
 * there is no error, remove the req class $(element).removeClassName('req'); } }
 * 
 *  // Create a new ajax request, note the .xml added to the url, it makes shure
 * we get an xml back from the controller.
 * 
 * new Ajax.Request('/regwiz/customer.xml', { asynchronous:true,
 * evalScripts:true, parameters:Form.Element.serialize(element),
 * onSuccess:handlerFunc } ); } </script>
 */